/*
 * Copyright 2010 Pierre Heinzerling, Uwe Janner, Patrick Wright
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var SHOW_LOG = false;

function writeLog(msg) {
    bg().writeLog(msg);
}

function removeAllRowsFromTable(tableId) {
    var table = elem(tableId);
    // table might be hidden already
    if (table) {
        for (var i = table.rows.length - 1; i > 0; i--) {
            table.deleteRow(i);
        }
    }
}
function elem(id) {
    var e = document.getElementById(id);
    if (e) {
        return e;
    }
    writeLog("ERROR: can't find HTML element with id '" + id + "'");
    return null;
}

function bg() {
    return chrome.extension.getBackgroundPage();
}

function dumpObjectProperties(obj) {
    writeLog("properties for unknown object:")
    for (property in obj) { writeLog("  " + property); }
}

function showWaiting() { 
	$("#waiting_img").show(); 
}
function notWaiting() { 
	$("#waiting_img").hide(); 
}